gdk: Add GDK_SEAT_CAPABILITY_TABLET_PAD
authorCarlos Garnacho <carlosg@gnome.org>
Mon, 27 Nov 2017 20:39:05 +0000 (21:39 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 8 Dec 2017 02:27:33 +0000 (21:27 -0500)
Tablet pads don't adapt really well to any other capability, so add a
distinct one to be able to query those properly.

https://bugzilla.gnome.org/show_bug.cgi?id=790920

gdk/gdkseat.h
gdk/gdkseatdefault.c
gdk/wayland/gdkdevice-wayland.c

index f60b93dd667c31bd53ad5dd69e39b94079238936..c7bc64d419646c4b0ad8e9870e177aa0fbdac1f1 100644 (file)
@@ -42,6 +42,7 @@ G_BEGIN_DECLS
  * @GDK_SEAT_CAPABILITY_TOUCH: The seat has touchscreen(s) attached
  * @GDK_SEAT_CAPABILITY_TABLET_STYLUS: The seat has drawing tablet(s) attached
  * @GDK_SEAT_CAPABILITY_KEYBOARD: The seat has keyboard(s) attached
+ * @GDK_SEAT_CAPABILITY_TABLET_PAD: The seat has drawing tablet pad(s) attached
  * @GDK_SEAT_CAPABILITY_ALL_POINTING: The union of all pointing capabilities
  * @GDK_SEAT_CAPABILITY_ALL: The union of all capabilities
  *
@@ -55,6 +56,7 @@ typedef enum {
   GDK_SEAT_CAPABILITY_TOUCH         = 1 << 1,
   GDK_SEAT_CAPABILITY_TABLET_STYLUS = 1 << 2,
   GDK_SEAT_CAPABILITY_KEYBOARD      = 1 << 3,
+  GDK_SEAT_CAPABILITY_TABLET_PAD    = 1 << 4,
   GDK_SEAT_CAPABILITY_ALL_POINTING  = (GDK_SEAT_CAPABILITY_POINTER | GDK_SEAT_CAPABILITY_TOUCH | GDK_SEAT_CAPABILITY_TABLET_STYLUS),
   GDK_SEAT_CAPABILITY_ALL           = (GDK_SEAT_CAPABILITY_ALL_POINTING | GDK_SEAT_CAPABILITY_KEYBOARD)
 } GdkSeatCapabilities;
@@ -112,7 +114,7 @@ GdkDevice *    gdk_seat_get_pointer      (GdkSeat             *seat);
 GDK_AVAILABLE_IN_3_20
 GdkDevice *    gdk_seat_get_keyboard     (GdkSeat             *seat);
 
-GDK_AVAILABLE_IN_3_93
+GDK_AVAILABLE_IN_3_94
 GList *        gdk_seat_get_master_pointers (GdkSeat             *seat,
                                              GdkSeatCapabilities  capabilities);
 
index bf3f41098bac73ccfc34e8ace7f88e73218d52c1..382cc042ba9cdbff6979c5e2cca32642939b4c77 100644 (file)
@@ -226,10 +226,11 @@ device_get_capability (GdkDevice *device)
     case GDK_SOURCE_ERASER:
     case GDK_SOURCE_CURSOR:
       return GDK_SEAT_CAPABILITY_TABLET_STYLUS;
+    case GDK_SOURCE_TABLET_PAD:
+      return GDK_SEAT_CAPABILITY_TABLET_PAD;
     case GDK_SOURCE_MOUSE:
     case GDK_SOURCE_TOUCHPAD:
     case GDK_SOURCE_TRACKPOINT:
-    case GDK_SOURCE_TABLET_PAD:
     default:
       return GDK_SEAT_CAPABILITY_POINTER;
     }
@@ -269,7 +270,7 @@ gdk_seat_default_get_slaves (GdkSeat             *seat,
   if (capabilities & (GDK_SEAT_CAPABILITY_ALL_POINTING))
     devices = append_filtered (devices, priv->slave_pointers, capabilities);
 
-  if (capabilities & GDK_SEAT_CAPABILITY_KEYBOARD)
+  if (capabilities & (GDK_SEAT_CAPABILITY_KEYBOARD | GDK_SEAT_CAPABILITY_TABLET_PAD))
     devices = append_filtered (devices, priv->slave_keyboards, capabilities);
 
   return devices;
@@ -375,7 +376,7 @@ gdk_seat_default_add_slave (GdkSeatDefault *seat,
 
   if (capability & GDK_SEAT_CAPABILITY_ALL_POINTING)
     priv->slave_pointers = g_list_prepend (priv->slave_pointers, g_object_ref (device));
-  else if (capability & GDK_SEAT_CAPABILITY_KEYBOARD)
+  else if (capability & (GDK_SEAT_CAPABILITY_KEYBOARD | GDK_SEAT_CAPABILITY_TABLET_PAD))
     priv->slave_keyboards = g_list_prepend (priv->slave_keyboards, g_object_ref (device));
   else
     {
@@ -415,8 +416,9 @@ gdk_seat_default_remove_slave (GdkSeatDefault *seat,
     {
       priv->slave_keyboards = g_list_remove (priv->slave_keyboards, device);
 
-      if (priv->slave_keyboards == NULL)
-        priv->capabilities &= ~GDK_SEAT_CAPABILITY_KEYBOARD;
+      priv->capabilities &= ~(GDK_SEAT_CAPABILITY_KEYBOARD | GDK_SEAT_CAPABILITY_TABLET_PAD);
+      for (l = priv->slave_keyboards; l; l = l->next)
+        priv->capabilities |= device_get_capability (GDK_DEVICE (l->data));
 
       gdk_seat_device_removed (GDK_SEAT (seat), device);
     }
index 02f9418a7ec81cb1263e26adf18ee126db8f3ed7..b1d0a00d2632e25b4a7d5a654ace5cc9adbf6f1e 100644 (file)
@@ -4711,6 +4711,17 @@ gdk_wayland_seat_get_slaves (GdkSeat             *seat,
         }
     }
 
+  if (wayland_seat->tablet_pads && (capabilities & GDK_SEAT_CAPABILITY_TABLET_PAD))
+    {
+      GList *l;
+
+      for (l = wayland_seat->tablet_pads; l; l = l->next)
+        {
+          GdkWaylandTabletPadData *data = l->data;
+          slaves = g_list_prepend (slaves, data->device);
+        }
+    }
+
   return slaves;
 }